package com.itheima.可变参数;

/**
 * @Author 王加鑫
 * @Date 2021/5/17 9:16
 * @Version 1.0
 * 可变形参
 */
public class Demo01 {
    public static void main(String[] args) {
        int sum = getSum(1, 2, 3, 4, 5);
        System.out.println(sum);
    }

    public static int getSum(int... arr){
        int sum = 0;
        for (int i = 1; i <= arr.length; i++) {
            sum += i;
        }

        return sum;
    }
}
